package com.huang;

import org.junit.jupiter.api.Test;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;

/**
 * @author HuangShen
 * @Description
 * @create 2021-03-31 18:25
 */
public class HashDemo {


    public static void main(String[] args) throws InterruptedException {

        ArrayList<Object> objects = new ArrayList<>();

        while (true){
            Thread.sleep(500);
           objects.add(new int[1024*1024]);
        }
    }

    @Test
    public  void test1(){
        try {
            //密文
            String s = "aa";
            //加密算法 SHA512  SHA256  SHA1  MD5
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            byte[] digest = md5.digest(s.getBytes());
            StringBuilder md5String = new StringBuilder();
            //转16进制
            for (byte b : digest) {
                String s1 = Integer.toHexString(b & 0xff);
                if (s1.length()<=1){
                    s1="0"+s1;
                }
                md5String.append(s1);
                Thread.sleep(100000);
            }
            System.out.println(md5String);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
